/**
 * 
 */
package game;

/**
 * @author Jean-Baptiste BORIC
 *
 */
public class BuildingType {
	
	private String name;
	private String[] images;
	private int defense;
	
	private boolean isEssential;
	
	/**
	 * @param name
	 * @param defense
	 * @param isEssential
	 */
	public BuildingType(String name, int defense, boolean isEssential) {
		super();
		this.setName(name);
		this.images = new String[5];
		this.setDefense(defense);
		this.setEssential(isEssential);
	}

	/**
	 * @return Name of the building
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name Name of the building
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param image ID of the image
	 * @return Name of the image
	 */
	public String getImage(int image) {
		return images[image];
	}

	/**
	 * @param images ID of image to set
	 * @param str Name of the image
	 */
	public void setImage(int image, String str) {
		this.images[image] = str;
	}

	/**
	 * @return Defense of the building
	 */
	public int getDefense() {
		return defense;
	}

	/**
	 * @param defense Defense of the building
	 */
	public void setDefense(int defense) {
		if(defense < 0 || defense > 5) {
			throw new IllegalArgumentException("Building defense not between 0 and 5");
		}
		this.defense = defense;
	}

	/**
	 * @return Essential flag
	 */
	public boolean isEssential() {
		return isEssential;
	}

	/**
	 * @param isEssential Essential flag
	 */
	public void setEssential(boolean isEssential) {
		this.isEssential = isEssential;
	}

	@Override
	public String toString() {
		String str = getName() + "\t";
		
		// Output image names
		for(int i = 0; i < 5; i++) {
			str += getImage(i) + "\t";
		}
		
		str += isEssential();
		
		// Fill unused data
		for(int i = 0; i < 7; i++) {
			str += "\t" + false;
		}
		
		return str;
	}
}
